package demo06;

public class Student implements Comparable <Student>{
    public String name;
    public int age;
    public int score;
    //构造方法
    public Student(String name,int age,int score){
        this.name = name;
        this.age = age;
        this.score = score;
    }
    public String toString(){
        return "Student{"+"name = '" +name +'\'' +", age = "+age +", score = "+score+'}';
    }

    @Override
    public int compareTo(Student o) {
        if (this.age >o.age){
            return 1;
        } else if (this.age ==o.age) {
            return 0;
        } else {
            return -1;
        }
    }
}
